<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>背景随机</title>

    <style>
        div{
            text-align: center;
            font-size: 50px;
            height: 600px;
        }

    </style>
</head>

<body>

<div id="content"><h1>嗨<br>起<br>来</h1></div>

</body>

</html>
<script>
    //2. 在页面上放置一个div，结合定时器实现该div的背景色不断随机变化
    var arr =["red","green","blue","yellow","pink","pueple","#fabcbb","#bbdcff","#ffbdac","#ddcbda"]

    function fun() {
        var res =Math.random()*arr.length;
        var number = Math.floor(res);
        document.getElementById("content").style.background = arr[number];
    }
    setInterval(fun, 500);

</script>
